//商票易贴审批中页面
<template>
  <div class="contents">
    <!-- 面包屑组件 -->
    <el-breadcrumb separator-class="el-icon-arrow-right" class="breadcrumb">
      <span class="back" @click="goBack">返回上一页</span>
      <el-breadcrumb-item>
        <img src="@/assets/user/icon.png" alt="" />
        <span class="span">项目管理</span>
      </el-breadcrumb-item>
      <el-breadcrumb-item>
        <span class="span" style="color: #666">商票驿</span>
      </el-breadcrumb-item>
      <el-breadcrumb-item>
        <span class="span" style="color: #666">项目详情</span>
      </el-breadcrumb-item>
    </el-breadcrumb>
    <!-- 一楼 -->
    <div class="f1">
      <div class="title" v-if="projectMessage">
        <p>{{ projectMessage.oderid }}</p>
        <h5
          :class="{
            spz: projectMessage.status == '审批中',
            sptg: projectMessage.status == '审批通过',
            spjj: projectMessage.status == '审批拒绝',
            djf: projectMessage.status == '待缴费',
            dfk: projectMessage.status == '待放款',
            yfk: projectMessage.status == '已放款',
            yyq: projectMessage.status == '已逾期',
            zcjx: projectMessage.status == '正常结项',
            yqjx: projectMessage.status == '逾期结项',
            yqx: projectMessage.status == '已取消'
          }"
        >
          {{ projectMessage.status }}
        </h5>
        <h5 style="background-color: #fda261">贴现</h5>
      </div>
      <!-- 产品信息 -->
      <div class="details" v-if="projectMessage">
        <div class="details-item">
          <div class="details-item-left">
            <ul>
              <li>产品名称：</li>
              <li>产品类型：</li>
              <li>贴现利率（%）：</li>
            </ul>
            <div>
              <p>{{ projectMessage.productname }}</p>
              <p>{{ projectMessage.producttype | getData }}</p>
              <p>{{ projectMessage.radio | getArea }}</p>
            </div>
          </div>
          <div class="details-item-left">
            <ul>
              <li>金融机构：</li>
              <li>放款日期：</li>
              <li>到期日：</li>
            </ul>

            <div style="width: 1.6146rem">
              <p>{{ projectMessage.orgname | getData }}</p>
              <p>{{ a.loandate | getDate }}</p>
              <p>{{ a.loanenddate | getDate }}</p>
            </div>
          </div>
        </div>
      </div>
    </div>
    <!-- 二楼 -->
    <div class="f2">
      <!-- 顶部标签 -->
      <div class="title">
        <h3 :class="{ active: row == 1 }" @click="row = 1">
          <a @click="changeHash('#box1')">项目信息</a>
        </h3>
      </div>
      <!-- 票据信息表格 -->
      <div class="f2-f2">
        <div class="titles">
          <h1></h1>
          <h3>项目进度</h3>
        </div>
        <div class="schedule">
          <div class="schedule1">
            <img src="@/assets/shangpiao/组194.png" alt="" />
            <h1></h1>
            <img src="@/assets/shangpiao/组194.png" alt="" />
            <h1></h1>
            <img src="@/assets/shangpiao/组194.png" alt="" />
          </div>
          <div class="schedule2">
            <div class="state">通过</div>
            <span>业务申请</span>
            <h2></h2>
            <span>项目审批</span>
            <h2></h2>
            <span>项目结项</span>
          </div>
          <div class="schedule3">
            <span>2020-12-12 13:23:45</span>
            <h3></h3>
            <span>2020-12-12 13:23:45</span>
            <h3></h3>
            <span>2020-12-12 13:23:45</span>
          </div>
        </div>
        <!-- <h2>申请信息</h2>
        <div class="details-item" v-if="a">
          <div class="details-item-left">
            <ul style="width: 220px; position: relative">
              <li>企业纳税信用等级：</li>
              <li>企业未结清融资机构数量：</li>
              <li>企业未结清融资金额（元）：</li>
              <li>企业当前是否存在逾期：</li>
              <li>可接受融资成本 (%)：</li>
            </ul>
            <div>
              <p>{{ a.enterprise }}</p>
              <p>{{ a.outstanding }}</p>
              <p>{{ a.entoutstanding | getArea }}</p>
              <p>{{ a.entoverdue }}</p>
              <p>{{ a.financing | getArea }}</p>
            </div>
          </div>
          <div class="details-item-left">
            <ul style="width: 315px">
              <li>企业是否存在征信不良记录：</li>
              <li>企业法定代表人是否存在严重违法记录：</li>
              <li>企业法定代表人是否存在行政处罚记录：</li>
              <li>企业法定代表人是否存在征信不良记录：</li>
              <li>企业法定代表人未结清经营贷款余额（元）：</li>
            </ul>
            <div style="width: 100px">
              <p>{{ a.entrecords }}</p>
              <p>{{ a.outrage }}</p>
              <p>{{ a.punishment }}</p>
              <p>{{ a.defaulter }}</p>
              <p>{{ a.operating | getArea }}</p>
            </div>
          </div>
        </div> -->
        <div class="titles">
          <h1></h1>
          <h3>项目详情</h3>
        </div>

        <!-- 融资信息-->
        <h2>
          票据信息
          <span @click="checkApply">
            <el-image
              style="width: 0.099rem; height: 0.0729rem"
              :src="icon"
              :preview-src-list="imgData"
            >
            </el-image>
          </span>
        </h2>
        <div class="details-item" v-if="b">
          <div class="details-item-left">
            <ul style="position: relative">
              <li>票据号码：</li>
              <li>票面金额（元）：</li>
              <li>票据到期日：</li>
            </ul>
            <div>
              <p>{{ b.billnumber | getData }}</p>
              <p>{{ b.faceamount | getArea }}</p>
              <p>{{ b.billdate | getDate }}</p>
            </div>
          </div>
          <div class="details-item-left">
            <ul>
              <li>承兑人名称：</li>
              <li>票据剩余天数：</li>
            </ul>

            <div style="width: 1.5625rem">
              <p>{{ b.acceptorname | getData }}</p>
              <p>{{ list.residualdate }}</p>
            </div>
          </div>
        </div>
        <h2>融资信息</h2>

        <div class="details-item" v-if="a">
          <div class="details-item-left">
            <ul style="width: 0.9375rem; position: relative">
              <li>金融机构：</li>
              <li>产品名称：</li>
              <li>产品类型：</li>
              <li>贴现利率（年化）：</li>
              <li>担保费率（年化）：</li>
              <li>担保服务费（元）：</li>
            </ul>

            <div style="width: 1.5104rem">
              <p>{{ projectMessage.orgname | getData }}</p>
              <p>{{ projectMessage.productname | getData }}</p>
              <p>{{ projectMessage.producttype | getData }}</p>
              <p>{{ projectMessage.radio | getData }}</p>
              <p>{{ a.guaranteerate | getArea }}</p>
              <p>{{ a.guaranteefee | getArea }}</p>
            </div>
          </div>

          <div class="details-item-left">
            <ul style="width: 0.9375rem">
              <li>预计到账金额（元）：</li>
              <li>预计退回尾款（元）：</li>
              <li>借款期限（月）：</li>
              <li>放款日期：</li>
              <li>技术服务费率（年化）：</li>
              <li>技术服务费（元）：</li>
            </ul>
            <div style="width: 0.9375rem">
              <p>{{ a.financingamount | getArea }}</p>
              <p>{{ a.returnmount | getArea }}</p>
              <p>{{ a.deadline | getData }}</p>
              <p>{{ a.loandate | getDate }}</p>
              <p>
                {{ a.technicalservicerate | getArea }}
                <i v-show="a.technicalservicerate">%</i>
              </p>
              <p>{{ a.technicalservice | getArea }}</p>
            </div>
          </div>
        </div>
      </div>
    </div>
    <!-- 查看票据正反面信息 -->
    <el-dialog title="票面信息" :visible.sync="contractCardbackVisible" width="40%" center>
      <!-- 内容区域 -->
      <div
        v-viewer
        v-if="frontImg.length != 0"
        style="text-align: center; width: 1.5625rem; height: 1.5625rem"
        class="dialog-center"
        @click="contractCardbackVisible = false"
      >
        <img
          v-for="(item, index) in frontImg"
          :key="index"
          style="width: 100%; height: 100%; margin-bottom: 0.0781rem"
          :src="item.path"
          alt=""
        />
        <!-- <img style="width: 100%; height: 100%" :src="reverseImg" alt="" /> -->
        <p style="margin-top: 20px">点击图片可查看大图</p>
      </div>
      <div v-else style="text-align: center; margin-bottom: 0.1563rem" class="dialog-center">
        <h4>暂无票据资料</h4>
      </div>
      <!-- 按钮区域 -->
      <!--  -->
      <!-- -->
      <div slot="footer" class="dialog-footer">
        <button class="dialog-footer-bnt btn1" @click="contractCardbackVisible = false">
          取 消
        </button>
        <button class="dialog-footer-bnt btn2" @click="contractCardbackVisible = false">
          确 定
        </button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { findSP, getFilePath } from '@/utils'
import { mapState } from 'vuex'
export default {
  data() {
    return {
      icon: 'http://operate.thunlink.cn/protocol/image/票.png',
      imgData: null,
      oderid: '',
      //产品数据
      row: 1,
      id: '', //项目id
      spid: '',
      frontImg: [], //票据正面
      contractCardbackVisible: false, //弹出框
      projectMessage: {
        oderid: '2023090800001',
        status: '审批拒绝',
        productname: '离开时俺说',
        producttype: '贴现',
        radio: '0.6',
        orgname: '北坳隧道'
      }, // 产品信息
      a: {
        loandate: '123123',
        loanenddate: '123123',
        enterprise: '123123',
        enterprise: '123123',
        entoutstanding: '123123',
        entoverdue: '123123',
        financing: '123123',
        financing: '123123',
        outrage: '123123',
        punishment: '123123',
        defaulter: '123123',
        operating: '123123',
        guaranteerate: '1255',
        guaranteefee: '255555'
      },
      b: {
        billnumber: '12555',
        faceamount: '12555',
        billdate: '12555'
      },
      list: {
        residualdate: '4555'
      }
    }
  },
  // 计算属性
  computed: {
    ...mapState(['shangPiaoDetailsParameter'])
  },
  mounted() {
    // // 获取地址栏中的id
    // this.id = this.shangPiaoDetailsParameter.id;
    // this.spid = this.shangPiaoDetailsParameter.spid;
    // // this.status = this.shangPiaoDetailsParameter.status;
    // this.findSP();
    // setTimeout(() => {
    //   this.checkApply();
    // }, 500);
  },
  // 过滤器
  filters: {
    getArea: function (value) {
      if (value === 0) {
        // 获取整数部分
        const intPart = Math.trunc(value)
        // 整数部分处理，增加,
        const intPartFormat = intPart.toString().replace(/(\d)(?=(?:\d{3})+$)/g, '$1,')
        // 预定义小数部分
        let floatPart = '.00'
        // 将数值截取为小数部分和整数部分
        const valueArray = value.toString().split('.')
        if (valueArray.length === 2) {
          // 有小数部分
          floatPart = valueArray[1].toString() // 取得小数部分
          return intPartFormat + '.' + floatPart
        }
        return intPartFormat + floatPart
      }
      if (value == '') return '-'
      if (!value) return '-'
      let num = Number(value)
      if (isNaN(num)) return '-'
      value = num.toFixed(2)
      // 获取整数部分
      const intPart = Math.trunc(value)
      // 整数部分处理，增加,
      const intPartFormat = intPart.toString().replace(/(\d)(?=(?:\d{3})+$)/g, '$1,')
      // 预定义小数部分
      let floatPart = '.00'
      // 将数值截取为小数部分和整数部分
      const valueArray = value.toString().split('.')
      if (valueArray.length === 2) {
        // 有小数部分
        floatPart = valueArray[1].toString() // 取得小数部分
        return intPartFormat + '.' + floatPart
      }
      return intPartFormat + floatPart
    },
    getDate: function (value) {
      if (!value) return '-'
      let date = value.split(' ')[0]
      return date
    },
    getData: function (value) {
      if (!value || value == '') {
        return '-'
      } else {
        return value
      }
    },
    getInte: function (value) {
      if (value) {
        return parseInt(value)
      } else {
        return '-'
      }
    }
  },
  methods: {
    async findSP() {
      let data = await findSP(this.spid, this.id)
      if (data.data.businessSPinfo) {
        this.oderid = data.data.oderid
        this.projectMessage = data.data
        this.a = data.data.businessSPinfo
        this.b = data.data.sPticketinfos[0]
        this.list = data.data.list[0]
      } else {
        this.$Message.error('数据错误')
      }
    },
    // 点击查看，查看票据信息
    async checkApply() {
      // let id = this.id;
      // let a = [];
      // let { data } = await getFilePath(id);
      // if (data) {
      //   if (data.length == 0) return this.$Message.error("暂无票据信息");
      //   for (let i = 0; i < data.length; i++) {
      //     a.push(data[i].path);
      //   }
      this.imgData = [
        'https://img2.baidu.com/it/u=3853345508,384760633&fm=253&app=120&size=w931&n=0&f=JPEG&fmt=auto?sec=1694278800&t=1ea15d7024294ab98fcbab788cc27f64'
      ]
      // }
    },
    // 返回上一页
    goBack() {
      this.$router.go(-1)
      setTimeout(() => {
        this.$router.go(0)
      }, 50)
    },
    changeHash(idName) {
      document.querySelector(idName).scrollIntoView(true)
    }
  }
}
</script>

<style lang="scss" scoped>
.contents {
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 100%;
  background-color: rgb(242, 244, 247);
  // 返回上一页
  .back {
    position: absolute;
    left: 3.9063rem;
    font-size: 0.0833rem;
    color: #3f6ef2;
    text-decoration: underline;
    user-select: none;
  }
  // 面包屑
  .breadcrumb {
    display: flex;
    align-items: center;
    height: 0.3958rem;
    font-size: 0.0833rem;
    background-color: rgb(242, 244, 247);
    .icon {
      margin: 0 0.0521rem 0 0.0208rem;
    }
    .span {
      font-size: 0.0833rem;
      font-family: Source Han Sans SC;
      font-weight: 400;
      color: #999999;
    }
    img {
      width: 0.0938rem;
      height: 0.0938rem;
      margin-right: 0.026rem;
    }
  }

  .f1 {
    box-sizing: border-box;
    padding: 0.1563rem 0.2604rem;
    width: 100%;
    background: #ffffff;
    box-shadow: 0px 0.0052rem 0.0521rem 0px rgba(196, 196, 196, 0.15);
    border-radius: 0.0313rem;
    margin: 0px 0 0.1042rem 0;

    overflow: auto;
    .title {
      display: flex;
      align-items: center;
      width: 100%;
      height: 0.125rem;
      p {
        font-size: 0.1042rem;
        font-family: Source Han Sans SC;
        font-weight: 400;
        color: #333333;
      }
      h5 {
        width: 0.3438rem;
        height: 0.0938rem;
        border-radius: 0.0104rem;
        font-size: 0.0729rem;
        font-family: Source Han Sans SC;
        font-weight: 400;
        color: #ffffff;
        text-align: center;
        line-height: 0.0938rem;
        margin-left: 0.0417rem;
        &.spz {
          background: #48a0b8;
        }
        &.sptg {
          background: #48b8a7;
        }
        &.spjj {
          background: #ff6060;
        }
        &.dfk {
          background: #f19149;
        }
        &.yfk {
          background: #13b5b1;
        }
        &.yyq {
          background: #ec6941;
        }
        &.zcjx {
          background: #80c269;
        }
        &.yqjx {
          background: #448aca;
        }
        &.yqx {
          background: #556fb5;
        }
        &.djf {
          background: #6291fa;
        }
      }
    }
    // <!-- 产品详细信息开始 -->
    .details {
      width: 100%;
      margin-left: 0.0521rem;
      .details-item {
        display: flex;
        width: 100%;

        .details-item-left {
          display: flex;
          width: 3.125rem;
          height: 100%;
          ul {
            width: 0.9375rem;
            height: 100%;
            font-size: 0.0885rem;
            font-family: Source Han Sans SC;
            font-weight: 400;
            color: #999999;
            overflow: hidden;
            white-space: nowrap;
            text-overflow: ellipsis;
            li {
              margin-top: 0.0625rem;
              height: 0.1563rem;
              background-color: #fff;
            }
          }
          div {
            width: 1.3021rem;
            height: 100%;
            margin-left: 0.0625rem;
            overflow: hidden;
            white-space: nowrap;
            text-overflow: ellipsis;
            z-index: 99;
            p {
              height: 0.1563rem;
              font-size: 0.0885rem;
              font-family: Source Han Sans SC;
              font-weight: 400;
              color: #4d4d4d;
              margin-top: 0.0625rem;
            }
          }
        }
      }
    }
  }
  .f2 {
    overflow: auto;
    flex: 1;
    width: 100%;
    box-sizing: border-box;
    background: #ffffff;
    box-shadow: 0px 0.0052rem 0.0521rem 0px rgba(196, 196, 196, 0.15);
    border-radius: 0.0313rem;
    padding: 0.2604rem;
    scroll-behavior: smooth;

    .title {
      display: flex;
      align-items: center;
      width: 100%;
      height: 0.3125rem;
      z-index: 99;
      h3 {
        height: 0.1667rem;
        width: 100%;
        line-height: 0.1458rem;
        box-sizing: border-box;
        font-size: 0.125rem;
        font-family: Source Han Sans SC;
        font-weight: bold;
        color: #222222;
      }
    }
    .f2-f2 {
      width: 100%;

      height: 275px;
      @media only screen and (min-width: 1100px) and (max-width: 1950px) {
        height: 700px;
      }
      overflow: auto;
      scroll-behavior: smooth;
      margin-top: 0.1563rem;
      // 进度
      .schedule {
        width: 100%;
        margin: 0.2604rem 0;
        .schedule1 {
          box-sizing: border-box;
          padding: 0 0.2344rem;
          display: flex;
          align-items: center;
          justify-content: space-evenly;
          width: 100%;
          height: 0.1823rem;

          img {
            width: 0.1823rem;
          }
          h1 {
            width: 2.4323rem;
            height: 0.0052rem;
            background: #3f6ef2;
          }
        }
        .schedule2 {
          position: relative;
          display: flex;
          align-items: center;
          justify-content: space-evenly;
          box-sizing: border-box;
          padding: 0 0.1823rem;
          width: 100%;
          height: 0.1823rem;
          h2 {
            width: 2.3438rem;
            height: 0.0052rem;
          }
          span {
            font-size: 0.1042rem;
            font-family: Source Han Sans SC;
            font-weight: 400;
            color: #3f6ef2;
          }
          .state {
            display: flex;
            justify-content: center;
            justify-items: center;
            position: absolute;
            left: 54%;
            width: 0.2083rem;
            height: 0.1042rem;
            background: #22b556;
            opacity: 0.8;
            border-radius: 0.0104rem;
            font-size: 0.0729rem;
            font-family: Source Han Sans SC;
            font-weight: 400;
            color: #ffffff;
          }
        }
        .schedule3 {
          display: flex;
          align-items: center;
          justify-content: space-evenly;
          width: 100%;
          height: 0.1823rem;
          h3 {
            width: 1.9271rem;
            height: 0.0052rem;
          }
          span {
            font-size: 0.0833rem;
            font-family: Source Han Sans SC;
            font-weight: 300;
            color: #8d93a1;
          }
        }
      }
      .titles {
        display: flex;
        align-items: center;
        height: 0.1563rem;
        h1 {
          height: 0.1042rem;
          width: 0.0313rem;
          background-color: #e8903c;
        }
        h3 {
          font-size: 0.1042rem;
          font-family: Source Han Sans SC;
          font-weight: 500;
          color: #e8903c;
          margin-left: 0.0625rem;
        }
      }

      .null {
        display: flex;
        flex-direction: column;
        align-items: center;
        width: 100%;
        height: 1.6146rem;
        img {
          width: 1.6979rem;
          height: 1.1042rem;
        }
        discount p {
          font-size: 0.0677rem;
          color: #666;
          margin-bottom: 0.0417rem;
          a {
            color: #48a0b8;
            cursor: pointer;
          }
          span {
            color: #48a0b8;
            text-decoration: underline;
            cursor: pointer;
          }
        }
      }
      .enquiry {
        display: flex;
        margin: 0.0521rem 0.0781rem;
        .enquiry-item {
          display: flex;
          width: 48%;
          height: 100%;
          ul {
            width: 0.8854rem;
            height: 100%;
            font-size: 0.0781rem;
            font-family: Source Han Sans SC;
            font-weight: 400;
            color: #999999;
            li {
              margin-top: 0.0521rem;
              height: 0.1563rem;
              background-color: #fff;
            }
          }
          div {
            width: 1.4583rem;
            height: 100%;
            margin-left: 0.0781rem;
            p {
              height: 0.1563rem;
              font-size: 0.0781rem;
              font-family: Source Han Sans SC;
              font-weight: 400;
              color: #4d4d4d;
              margin-top: 0.0521rem;
            }
          }
        }
      }
      h2 {
        font-size: 0.0938rem;
        font-family: Source Han Sans SC;
        font-weight: 500;
        color: #000000;
        margin: 0.151rem 0 0.0521rem 0;
        span {
          img {
            margin-right: 0.026rem;
            margin-top: -0.0208rem;
          }
          cursor: pointer;
          margin-left: 0.0781rem;
          font-size: 0.0833rem;
          font-family: Source Han Sans SC;
          font-weight: 400;
          text-decoration: underline;
          color: #48a0b8;
        }
      }
      // 基本信息
      .details-item {
        // background-color: #f00;
        display: flex;
        // justify-content: space-around;
        margin: 0.0521rem 0px;
        .details-item-left {
          display: flex;
          width: 3.125rem;
          height: 100%;
          ul {
            // background: #f00;
            width: 0.7813rem;
            height: 100%;
            font-size: 0.0938rem;
            font-family: Source Han Sans SC;
            font-weight: 400;
            color: #808080;
            overflow: hidden;
            white-space: nowrap;
            text-overflow: ellipsis;
            li {
              margin-top: 0.0781rem;
              height: 0.1563rem;
              background-color: #fff;
            }
          }
          div {
            width: 0.7031rem;
            height: 100%;
            margin-left: 0.0781rem;
            overflow: hidden;
            white-space: nowrap;
            text-overflow: ellipsis;
            z-index: 99;
            p {
              height: 0.1563rem;
              font-size: 0.0938rem;
              font-family: Source Han Sans SC;
              font-weight: 400;
              color: #000000;
              margin-top: 0.0781rem;
            }
          }
        }
      }
      // 表格编辑/查看
      .span {
        display: inline-block;
        width: 0.1563rem;
        height: 0.125rem;
        font-size: 0.0729rem;
        font-family: Source Han Sans SC;
        font-weight: 400;
        color: #56b1ca;
        border-bottom: 0.0052rem solid #56b1ca;
        cursor: pointer;
      }
    }
  }
  // 弹出框
  .dialog-center {
    width: 90%;
    margin: 0 auto;
  }
  .dialog-footer {
    display: flex;
    justify-content: space-evenly;
    width: 70%;
    margin: 0 auto;
    .dialog-footer-bnt {
      width: 121px;
      height: 31px;
      color: #48a0b8;
      border: 1px solid #56b1ca;
      border-radius: 4px;
      background-color: #fff;
    }
    .btn2 {
      color: #fff;
      background-color: #58b2cb;
    }
  }
  .abc {
    width: 368px;
    .el-select {
      width: 100%;
    }
  }
  .el-form-item {
    margin-bottom: 15px;
    .file {
      font-size: 15px;
      margin-right: 10px;
      color: #48a0b8;
      text-decoration: underline;
      cursor: pointer;
    }
    .file1 {
      color: #999;
    }
  }
  // 弹出框
  .dialog-center {
    margin: 0 auto;
    width: 90%;
  }
  .dialog-footer {
    display: flex;
    justify-content: space-evenly;
    width: 70%;
    margin: 0 auto;
    .dialog-footer-bnt {
      width: 121px;
      height: 31px;
      color: #48a0b8;
      border: 1px solid #56b1ca;
      border-radius: 4px;
      background-color: #fff;
    }
    .btn2 {
      color: #fff;
      background-color: #58b2cb;
    }
  }
}
</style>
<style lang="scss">
/* 表格 */
.el-table {
  th.el-table__cell > .cell {
    font-size: 0.0833rem;
    font-weight: 400;
  }
  .cell {
    font-size: 0.0833rem;
  }
}
.el-table tr {
  height: 0.2083rem;
}
.el-table thead {
  height: 0.2083rem;
}
.el-button--small {
  padding: 0;
}
</style>
